<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
    <meta name="author" content="Coderthemes">
	
	<!-- jQuery  -->
    <script type="text/javascript" src="/static/plugins/jquery/jquery-3.6.0.min.js"></script>
	
	<!-- layui  -->
	<link rel="stylesheet" href="/static/plugins/layui/2.7.6/css/layui.css" media="all" />
	<script src="/static/plugins/layui/2.7.6/layui.js" charset="utf-8"></script>
	
	<!-- 基于laiui的表格 -->
	<script type="text/javascript" src="/static/js/business/tpBoutiqueDiscount/simple_table_choiceshop_price.js"></script>
	
</head>
<body>

<div class="layui-layout layui-layout-admin">
	<form class="layui-form" id="formId" method="post" action="/api/inter/tpBoutiqueDiscount/setting">
		
		<div class="layui-inline header-btn" style="margin-left: 10px;">
			<button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="formSubmit"><i class="iconfont icon-save"></i>保存</button>
		</div>
		<div class="layui-body">
				
			<div style="width:95%; height:300px; overflow:scroll">
				<div id="simple_table_choiceshop_price">
				</div>
			</div>
			<script th:inline="javascript">
			var tableOfChoiceshopPrice = null;
			//使用layui的sku模块
			layui.use(['form', 'simple_table_choiceshop_price', 'jquery'], function(){
				var $ = layui.jquery,simple_table_choiceshop_price = layui.simple_table_choiceshop_price,form = layui.form;
	           	
				tableOfChoiceshopPrice = simple_table_choiceshop_price.init({ id:'simple_table_choiceshop_price', data: $.parseJSON(JSON.stringify([[${dto.priceArr}]]))  });
			});
			</script>
		</div>
	</form>
</div>
	<script>
	$(function () {
		layui.use(['form'], function(){
			var form = layui.form;
			
			// 表单提交，共用同一个
			form.on('submit(formSubmit)', function(data){
				var indexOfLoading = layer.load(1, {
					shade: [0.5,'#000000'] //0.1透明度的白色背景
				});

				data.field['priceArr'] = JSON.stringify(tableOfChoiceshopPrice.getData());
				$.post(data.form.action, data.field, function(res){
					if (res.code == 0) {
						layer.msg('操作成功');
						var dto = res.data;
						setTimeout(function(){
							layer.close(indexOfLoading);
							return;
						}, 2000);
					} else {
						layer.close(indexOfLoading);
						layer.msg(res.msg);
					}
				});
				return false;
			});
		});
	});
	</script>
</body>
</html>
